package com.hu.bgp.server;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;

import com.hu.bgp.exceptions.BgpServerException;

/**
 * Een collectie van gametypes.
 * 
 * @author ejvos
 */
public class GameTypeCollection implements Iterable<GameType>
{
	private Hashtable<String, GameType> collection = new Hashtable<String, GameType>();
	
	public GameType getByAlias(String alias)
	{
		GameType ret = collection.get(alias);
		if(ret == null)
			throw new BgpServerException("GameType not found"); 
		return ret;
	}

	
	public void add(GameType gameType)
	{
		if(collection.contains(gameType.getAlias()))
			throw new BgpServerException("GameType already excists!");
		collection.put(gameType.getAlias(), gameType);
	}
	



	public Iterator<GameType> iterator() {
		// TODO Auto-generated method stub
		return collection.values().iterator();
	}
}
